import request from '@/utils/request'

// 获取试卷列表及答题统计
export function getPapersWithStats(query) {
  return request({
    url: '/manage/mark/papers',
    method: 'get',
    params: query
  })
}

// 获取指定试卷的所有学生答题情况
export function getAnswersByPaperId(paperId, query) {
  return request({
    url: `/manage/mark/paper/${paperId}/answers`,
    method: 'get',
    params: query
  })
}

// 获取学生答题详情
export function getAnswerDetail(answerId) {
  return request({
    url: `/manage/mark/answer/${answerId}`,
    method: 'get'
  })
}

// 批阅试卷
export function markPaper(answerId, data) {
  return request({
    url: `/manage/mark/mark/${answerId}`,
    method: 'post',
    data: data
  })
}

// 导出成绩
export function exportGrades(paperId) {
  return request({
    url: `/manage/mark/export/${paperId}`,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }
  })
}

// 获取试卷平均分
export function getPaperAvgScore(paperId) {
  return request({
    url: `/manage/mark/avg-score/${paperId}`,
    method: 'get'
  })
}

// 获取所有试卷平均分
export function getAllPaperAvgScores() {
  return request({
    url: `/manage/mark/avg-scores`,
    method: 'get'
  })
}

// 全部重批
export function remarkAll(paperId) {
  return request({
    url: '/manage/mark/remarkAll/' + paperId,
    method: 'put'
  })
}

// 删除学生答题记录
export function deleteStudentAnswer(paperId, studentId) {
  return request({
    url: `/manage/mark/deleteAnswer/${paperId}/${studentId}`,
    method: 'delete'
  })
}


